local qixing = fk.CreateSkill {
  name = "th_qixing",
  max_phase_use_time = function(self, player)
    return math.max(player:getLostHp(), 1)
  end
}

qixing:addEffect("active", {
  anim_type = "drawcard",
  prompt = "#th_qixing",
  times = function(self, player)
    return player.phase == Player.Play and qixing:getRemainUseTime(player, Player.HistoryPhase) or -1
  end,
  card_num = 0,
  target_num = 0,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local judge = {
      who = player,
      reason = qixing.name,
      pattern = ".|.|red",
      -- skipDrop = true,
    }
    room:judge(judge)
  end
}, { check_skill_limit = true })

qixing:addEffect(fk.FinishJudge, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and data.reason == qixing.name and
    data.card.color == Card.Red and player.room:getCardArea(data.card.id) == Card.Processing
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:obtainCard(player, data.card, true, nil, player, qixing.name)
  end,
})

Fk:loadTranslationTable{
  ["th_qixing"] = "祈星",
  [":th_qixing"] = "出牌阶段限X次，你可以判定并获得红色判定牌（X为你已损失的体力值，至少为1）。",

  ["#th_qixing"] = "祈星：进行一次判定，若为红色，你获得之",
}

return qixing